/*
 * Copyright (C) 2019 ~ 2021 UnionTech Software Technology Co., Ltd.
 *
 * Author:     caitao <caitao@uniontech.com>
 *
 * Maintainer: caitao <caitao@uniontech.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once
#include <DFrame>

#include <DLabel>
#include <QPushButton>

DWIDGET_USE_NAMESPACE

class CChartWidget : public QWidget
{
    Q_OBJECT
public:
    explicit CChartWidget(QWidget *parent = nullptr);
    ~CChartWidget() override;

private:
    void initUi();

public:
    void setXAxisItemTextList(const QList<QString> &list);
    void setXItemTopTextList(const QList<QString> &list);
    void setXItemValueList(const QList<qreal> &list);
    void setXItemRectColor(const QColor &color);
    void setXAxisDescText(const QString &desc);

    void setYAxisItemTextList(const QList<QString> &list);
    void setYMaxValue(qreal value);
    void setYMinValue(qreal value);
    void setYAxisDescText(const QString &desc);

protected:
    virtual void paintEvent(QPaintEvent *e) override;
    virtual void mousePressEvent(QMouseEvent *e) override;

signals:
    void xItemClicked(int index);

private:
    QList<QString> m_xAxisItemTextList; // x轴单元文字列表
    QList<QString> m_xItemTopTextList; // x轴单元头部文字列表
    QList<qreal> m_xItemValueList; // x轴单元值列表
    QList<QRect> m_xItemRectList; // x轴单元矩形列表
    QColor m_xItemRectColor; // x轴单元矩形颜色
    QString m_xAxisDescText; // x轴说明

    QList<QString> m_yAxisItemTextList; // y轴单元文字列表
    qreal m_yMaxValue; // y轴最大值
    qreal m_yMinValue; // y轴最小值
    QString m_yAxisDescText; // y轴说明
    DLabel *m_label = nullptr; // 文字标签
};
